fix: shorten /routing/v1 stale windows#1195
Open
lidel wants to merge 1 commit into
Open
Conversation
Caches were told they may serve a two day old answer while the origin is healthy. The 48h window matches Amino DHT provider record expiration, but responses mostly carry peer addresses drawn from short-lived sources such as relay reservations, so clients kept getting addrs that stopped working long ago. - stale-while-revalidate: 10m with results, 1m without, enough to cover a background refresh - stale-if-error: 48h with results, 1h without, it only applies when the origin is failing - max-age unchanged
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #1195 +/- ##
==========================================
+ Coverage 63.89% 63.90% +0.01%
==========================================
Files 269 269
Lines 27115 27120 +5
==========================================
+ Hits 17325 17331 +6
+ Misses 8080 8079 -1
Partials 1710 1710
... and 13 files with indirect coverage changes 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
/routing/v1responses tell caches they may serve a two day old answer, and CDNs take that literally: two requests for the same CID minutes apart can come back with different providers, or none, and the older one wins until it ages out. The 48h is the Amino DHT provider record expiration, but most of what a response carries is peer addresses, and those come from short-lived sources such as relay reservations. Two days of stale hands clients relay addrs that died long ago.Fix
stale-while-revalidatedrops to 10 minutes with results, 1 minute without. It is served while the origin is healthy, so it only needs to cover a background refresh.stale-if-errorkeeps 48h with results, 1 hour for empty ones. It only fires when the origin is failing, where a stale answer beats no answer.max-ageis unchanged at 300s / 15s.Hot CIDs still revalidate in the background, so this costs no extra lookups there. The spec leaves the value open1; this reads "maximum cache window" as the address lifetime rather than the record lifetime.
Footnotes
Delegated Routing V1, section 4.1.4:
max-ageSHOULD be shorter for empty results, andmax-ttlSHOULD be "set to the maximum cache window of the underlying routing system". Same wording in 5.1.4 and 7.1.3. ↩